/*
 * @Author: your name
 * @Date: 2019-11-29 15:35:42
 * @LastEditTime: 2019-11-30 12:25:44
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \web\avue-cli\src\store\modules\equipmentLedger.js
 */
import {
  getSupplierType , getSupplierAll
} from "@/api/sysSetup/supplierManage";
import {
  getWarehouseList
} from "@/api/sysSetup/warehouse";
export default {
  namespaced: true,
  state: {
    equipmentInfo: null, //设备信息（台账）
    supplierType: [], //供应商类型
    warehouseList: [], //仓库数据列表
  },
  getters: {},
  mutations: {
    //设备信息（台账）
    setEquipmentLedger(state, data) {
      state.equipmentInfo = data
    },
    //供应商类型
    setSupplierType(state, data) {
      state.supplierType = data
    },
    //仓库数据
    setWarehouseList(state, data) {
      state.warehouseList = data
    },
  },
  actions: {
    _getSupplierType({ //供应商类型
      commit
    }) {
      getSupplierType().then(res => {
        if (res.data.code === 200) {
          commit('setSupplierType', res.data.data)
        } else {
          this.$notify.error({
            title: '查询失败',
            message: '获取数据失败！',
            type: 'danger',
          });
        }
      })
    },
  _getSupplierAll({ //供应商
       commit
   }) {
      getSupplierAll().then(res => {
          if (res.data.code === 200) {
              commit('setSupplierType', res.data.data)
          } else {
              this.$notify.error({
                  title: '查询失败',
                  message: '获取数据失败！',
                  type: 'danger',
              });
          }
      })
  },
    _getWarehouseList({ //仓库数据分页查询
      commit
    }, parmas) {
      getWarehouseList(parmas).then(res => {
        if (res.data.code === 200) {
          commit('setWarehouseList', res.data.data)
        } else {
          this.$message.error('获取数据失败!')
        }
      })
    }

  }
}